package jdbc;

import java.net.ConnectException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class JDBCDemo4 {
	public static void main(String[] args) {
		//查看所有老师的相关信息
		try(
				Connection connection = DBUtil.getConnection();
		
		){
			String sql = "SELECT id,name,salary,title " +
					"from teacher";
			
			Statement statement = connection.createStatement();
			ResultSet rs = statement.executeQuery(sql);
			while(rs.next()){
				int id = rs.getInt("id");
				String name = rs.getString("name");
				int age = rs.getInt("salary");
				String title = rs.getString("title");
				System.out.println(id+"--"+name+"--"+age+"--"+title);
			}
		}catch(Exception e){
			e.printStackTrace();
		}
	}
}
